// @ts-ignore
import _ from "lodash";
import { useLocalStorage } from "@vueuse/core";
import type { IColumn } from "@/types";
export const token: globalThis.Ref<string> = useLocalStorage("token", "");
/**
 * 表格基本列 大部分的表格都会存在的字段
 */
export namespace BaseTable {
  export const baseColumn = []
  export const generateBaseColumn = (columns:IColumn[]) => {
    //默认所有列都展示
    columns.map(item => {
      if (item.child) {
        item.child.map((it:any) => {
          (it.show === undefined) && (it.show = true);
          (it.sto === undefined) && (it.sto = true)
        })
      } else {
        (item.show === undefined) && (item.show = true);
        (item.sto === undefined) && (item.sto = true)
      }
    })
  }
}
/**
 * 程序休眠方法
 * @param number
 */
export const sleep = (number: number) => new Promise(resolve => {
  setTimeout(() => {
    resolve(null)
  }, number)
})

export const nullDefaultTrue = (data:boolean) => _.isNil(data) ? true : data


const columns = <IColumn[]>[
  {
    dataIndex: "name",
    title: "Name",
  },
  {
    dataIndex: "sex",
    title: "性别"
  }
]
type IDataSource = {
  name: any
  sex: any
}

const dataSource = <IDataSource[]>[
  {
    name: "测试",
    sex: 1
  }
]